package com.otojob.controller;

import com.otojob.dto.WxLoginDTO;
import com.otojob.service.WechatAuthService;
import com.otojob.utils.JwtUtils;
import com.otojob.utils.Results;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.UUID;

/**
 * @Description
 * @Author: TingFeng
 * @CreateTime: 2022/3/25  18:42
 */

@RestController
@Api(value = "WechatAuthController", tags = "微信授权模块")
@CrossOrigin
@RequestMapping("/wx")
public class WechatAuthController {
    @Resource
    private WechatAuthService wechatAuthService;


    @ApiOperation("微信授权登录接口")
    @PostMapping("/login")
    public Results wechatLogin( @Valid @RequestBody WxLoginDTO wxLoginDTO){

//        System.out.println(wxLoginDTO.getCode());
//        System.out.println(wxLoginDTO.getNickName());
//    public Results wechatLogin(String code ){
//        WxLoginDTO wxLoginDTO = new WxLoginDTO();
//        String name = "用户"+UUID.randomUUID().toString().replaceAll("-","");
//        wxLoginDTO.setAvatarUrl("https://myotojob.oss-cn-beijing.aliyuncs.com/Resume/2022/03/28/b64faac44d304afe8b3e2df747bbfc9492230361_p0.jpg");
//        wxLoginDTO.setNickName(name);
//        wxLoginDTO.setCode(code);
//        System.out.println(wxLoginDTO.getCode());
        return wechatAuthService.wechatLogin(wxLoginDTO);
    }
    @ApiOperation("伪登录接口")
    @GetMapping("/loginVo")
    public Results Login(){
        String jwtToken = JwtUtils.getJwtToken(1,"听风不起雨");
        return Results.ok().data("token",jwtToken);
    }

//    @ApiOperation("验证Token")
//    @PostMapping("/checkToken")
//    public Results checkToken(){
//        return wechatAuthService.checkToken();
//    }

//    @ApiOperation("开发者授权登录")
//    @PostMapping("/devAuthLogin")
//    public Results devAuthLogin(){
//        return wechatAuthService.devAuthLogin();
//    }


}
